package com.boluo.web.controller.custom;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.boluo.common.annotation.Log;
import com.boluo.common.core.controller.BaseController;
import com.boluo.common.core.domain.AjaxResult;
import com.boluo.common.enums.BusinessType;
import com.boluo.custom.domain.CusFollow;
import com.boluo.custom.service.ICusFollowService;
import com.boluo.common.utils.poi.ExcelUtil;
import com.boluo.common.core.page.TableDataInfo;

/**
 * 客户回访Controller
 * 
 * @author ruoyi
 * @date 2023-04-17
 */
@RestController
@RequestMapping("/custom/cusFollow")
public class CusFollowController extends BaseController
{
    @Autowired
    private ICusFollowService cusFollowService;

    /**
     * 查询客户回访列表
     */
    @PreAuthorize("@ss.hasPermi('custom:cusFollow:list')")
    @GetMapping("/list")
    public TableDataInfo list(CusFollow cusFollow)
    {
        startPage();
        List<CusFollow> list = cusFollowService.selectCusFollowList(cusFollow);
        return getDataTable(list);
    }

    /**
     * 导出客户回访列表
     */
    @PreAuthorize("@ss.hasPermi('custom:cusFollow:export')")
    @Log(title = "客户回访", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CusFollow cusFollow)
    {
        List<CusFollow> list = cusFollowService.selectCusFollowList(cusFollow);
        ExcelUtil<CusFollow> util = new ExcelUtil<CusFollow>(CusFollow.class);
        util.exportExcel(response, list, "客户回访数据");
    }

    /**
     * 获取客户回访详细信息
     */
    @PreAuthorize("@ss.hasPermi('custom:cusFollow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(cusFollowService.selectCusFollowById(id));
    }

    /**
     * 新增客户回访
     */
    @PreAuthorize("@ss.hasPermi('custom:cusFollow:add')")
    @Log(title = "客户回访", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CusFollow cusFollow)
    {
        return toAjax(cusFollowService.insertCusFollow(cusFollow));
    }

    /**
     * 修改客户回访
     */
    @PreAuthorize("@ss.hasPermi('custom:cusFollow:edit')")
    @Log(title = "客户回访", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CusFollow cusFollow)
    {
        return toAjax(cusFollowService.updateCusFollow(cusFollow));
    }

    /**
     * 删除客户回访
     */
    @PreAuthorize("@ss.hasPermi('custom:cusFollow:remove')")
    @Log(title = "客户回访", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cusFollowService.deleteCusFollowByIds(ids));
    }
}
